use sea_orm::entity::prelude::*;
use salvo::prelude::*;
use serde::{Deserialize, Serialize};
use chrono::NaiveDateTime;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "role_menu")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub role_id: String,
    pub menu_id: String,
    pub tenant_id: Option<i64>,
    pub create_time: NaiveDateTime,
    pub create_by: String,
    pub update_time: NaiveDateTime,
    pub update_by: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}

#[derive(Serialize, Deserialize, Extractible, Debug)]
#[salvo(extract(default_source(from = "body", parse = "json")))]
pub struct RoleMenu {
    pub id: i64,
    pub role_id: String,
    pub menu_id: String,
    pub tenant_id: Option<i64>,
    pub create_time: NaiveDateTime,
    pub create_by: String,
    pub update_time: NaiveDateTime,
    pub update_by: String,
}
